<template>
  <div class="w-table-filter-container" @keyup.enter="save">
    <el-input
      v-model.trim="filterData.studentCode"
      class="w-table-filter-input"
      placeholder="请输入学号"
      clearable
    />

    <el-input
      v-model.trim="filterData.studentName"
      class="w-table-filter-input"
      placeholder="请输入姓名"
      clearable
    />

    <el-input
      v-model.trim="filterData.studentCallNum"
      class="w-table-filter-input"
      placeholder="请输入手机号"
      show-word-limit
      maxlength="11"
      clearable
    />

    <el-button type="success" icon="search" @click="save"> 搜索 </el-button>
    <el-button type="info" icon="refresh" style="margin-left: 0" @click="clear"> 重置 </el-button>
  </div>
</template>

<script setup>
const emits = defineEmits(['save'])
const { proxy } = getCurrentInstance()

// data
const def = {}
const filterData = ref(JSON.parse(JSON.stringify(def)))

// 方法
function clear() {
  for (let f1 in filterData.value) {
    filterData.value[f1] = def[f1] || ''
  }
  save()
}

function save() {
  const d = { ...filterData.value }
  emits('save', d)
}
</script>

<style lang="scss" scoped>
.w-table-filter-container {
  display: flex;
  gap: 15px;
}
.w-table-filter-input {
  width: 150px;
}
</style>
